package humanMirror.model.human;

/**
 * This simple class is used for storing an information about one organ.
 *
 * @author Anton Samarsky
 * @version 1.02 26 jul 2012
 */
public class OneOrganInfo {

    private int organParameters[];

    public OneOrganInfo() {
        organParameters = new int[SomeConstants.MAX_COUNT_OF_PARAMS];
    }

    public OneOrganInfo(int countOfParams) {
        argumentNumberCheck(countOfParams);
        organParameters = new int[countOfParams];
    }

    public OneOrganInfo(int... values) {
        int length = values.length;
        argumentNumberCheck(length);
        organParameters = new int[length];
        setParameters(values);
    }

    private void argumentNumberCheck(int argumentNumber) {
        if (argumentNumber > SomeConstants.MAX_COUNT_OF_PARAMS) {
            throw new IllegalArgumentException("The number of values has to be less than number in " +
                    "SomeConstants.MAX_COUNT_OF_PARAMS, but it is " + argumentNumber);
        }
    }

    public void set(int paramNumber, int value) {
        organParameters[paramNumber] = value;
    }

    public void setParameters(int... values) {
        organParameters = values;
    }

    public int get(int paramNumber) {
        return organParameters[paramNumber];
    }

    public void add(int paramNumber, int value) {
        organParameters[paramNumber] += value;
    }

    public int getCountOfParameters() {
        return organParameters.length;
    }

    public OneOrganInfo copy() {
        OneOrganInfo copyOfThisClass = new OneOrganInfo(organParameters.length);
        for (int paramNumber = 0; paramNumber < organParameters.length; paramNumber++) {
            copyOfThisClass.set(paramNumber, organParameters[paramNumber]);
        }
        return copyOfThisClass;
    }
}
